package cn.doitedu.flink.sources;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;

import java.util.Random;

public class RandomString extends RichSourceFunction<String> {
    @Override
    public void run(SourceContext sourceContext) throws Exception {
        Random random = new Random();
        while(true){
            String s1 = RandomStringUtils.random(2, true, false).toUpperCase();
            String s2 = RandomStringUtils.random(2, true, false).toUpperCase();
            sourceContext.collect(s1+","+s2);
            Thread.sleep(1000);
        }
    }

    @Override
    public void cancel() {

    }
}
